var t = require("../../../@babel/runtime/helpers/typeof"), o = getApp();

Component({
    properties: {
        goodsId: {
            type: null
        },
        enterAt: {
            type: null
        },
        leaveAt: {
            type: null
        },
        hoet: {
            type: null
        },
        mark: {
            type: null
        },
        markId: {
            type: null
        }
    },
    data: {
        stop1: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/stop1.png",
        play1: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/play1.png",
        phone1: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/phone1.png",
        weixin1: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/weixin.png",
        bfstatus: !1,
        posterShow: !1,
        innerAudioContext: null
    },
    lifetimes: {
        attached: function() {
            this.getData(), this.init(), console.log(this.data.goodsId);
        },
        moved: function() {},
        detached: function() {
            this.data.innerAudioContext.destroy();
        }
    },
    methods: {
        onlinekf: function(t) {
            console.log(t), wx.setClipboardData({
                data: this.data.people_connect,
                success: function(t) {
                    wx.getClipboardData({
                        success: function(t) {
                            wx.showToast({
                                title: "已复制链接请用浏览器打开",
                                icon: "none"
                            });
                        }
                    });
                }
            });
        },
        phone: function(t) {
            console.log(this.data.ConnectionInfo.phone);
            var o = this.data.ConnectionInfo.phone;
            wx.makePhoneCall({
                phoneNumber: o
            });
        },
        posterClose: function(t) {
            this.setData({
                posterShow: !1
            });
        },
        popupSpecs: function(t) {
            this.getMessage(), this.setData({
                posterShow: !0
            });
        },
        tapzt: function(t) {
            this.data.innerAudioContext.pause(), this.setData({
                bfstatus: !this.data.bfstatus
            });
        },
        gotoGoods: function(t) {
            console.log(t.currentTarget.id), wx.navigateTo({
                url: "/packageA/detail_v2/detail_v2?id=" + t.currentTarget.id
            });
        },
        tapbf: function(t) {
            this.setData({
                bfstatus: !this.data.bfstatus
            }), console.log(t.currentTarget.dataset.dali.url);
            var o = t.currentTarget.dataset.dali.url;
            this.data.innerAudioContext.src = o, this.data.innerAudioContext.play();
        },
        gotoindex: function() {
            wx.reLaunch({
                url: "/packageG/index/index"
            });
        },
        gotoMember: function() {
            wx.reLaunch({
                url: "/packageG/member_v2/member_v2"
            });
        },
        getMessage: function() {
            var t = this, n = o.getNetAddresss("plugin.voice-goods.api.voice-goods.getConnection");
            o._postNetWork({
                url: n,
                success: function(o) {
                    var n = o.data;
                    1 == n.result && t.setData({
                        ConnectionInfo: n.data,
                        people_connect: n.data.people_connect
                    });
                },
                fail: function(t) {}
            });
        },
        getData: function() {
            console.log(this.data.goodsId);
            var t = this, n = o.getNetAddresss("plugin.voice-goods.api.voice-goods.getVoiceGoods");
            o._postNetWork({
                url: n,
                data: {
                    goods_id: t.data.goodsId
                },
                success: function(o) {
                    t.setData({
                        goodsInfo: o.data.data,
                        is_rule: 1 == o.data.data.is_rule
                    }), wx.setNavigationBarTitle({
                        title: o.data.data.title
                    });
                },
                fail: function(t) {}
            });
        },
        init: function() {
            var t = this, o = this;
            this.data.innerAudioContext = wx.createInnerAudioContext(), this.data.innerAudioContext.onCanplay(function() {}), 
            this.data.innerAudioContext.onPlay(function() {
                console.log("开始播放"), console.log(t.data.innerAudioContext.duration), t.setData({
                    currentTime: t.realFormatSecond(t.data.innerAudioContext.duration),
                    slmin: "0:00:00"
                });
            }), this.data.innerAudioContext.onTimeUpdate(function() {
                setTimeout(function() {
                    var n = t.data.innerAudioContext.currentTime / t.data.innerAudioContext.duration * 100, e = parseInt(n);
                    console.log(t.data.innerAudioContext.duration), o.setData({
                        currentTime: t.realFormatSecond(t.data.innerAudioContext.duration),
                        slmin: t.realFormatSecond(t.data.innerAudioContext.currentTime),
                        valueSlmin: e,
                        audio_length: t.data.innerAudioContext.duration
                    });
                }, 1e3);
            }), this.data.innerAudioContext.onError(function(t) {
                wx.showToast({
                    title: "播放错误",
                    icon: "none"
                });
            });
        },
        sildein: function(t) {
            console.log(t);
            var o = t.detail.value / 100, n = this.data.audio_length * o;
            console.log(n, o), this.data.innerAudioContext.seek(n);
        },
        realFormatSecond: function(o) {
            var n = t(o);
            if ("number" === n || "string" === n) {
                o = parseInt(o);
                var e = Math.floor(o / 3600);
                o -= 3600 * e;
                var a = Math.floor(o / 60);
                return o -= 60 * a, e + ":" + ("0" + a).slice(-2) + ":" + ("0" + o).slice(-2);
            }
            return "0:00:00";
        }
    }
});